package com.example.task2.customer;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import org.apache.logging.log4j.message.Message;

import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.validation.constraints.Email;
import javax.validation.constraints.NotBlank;


@Entity
@Table
public class Customer {

    @JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
    @NotBlank
    private  String password;

    @NotBlank(message="name不可以为空")
    private  String name;

    @Id
    private  long id;
    @NotBlank(message="Email不可以为空")
    @Email
    private  String email ;

    public Customer(String name, long id, String password, String email) {
        this.name = name;
        this.id = id;
        this.password = password;

        this.email = email;
    }

    public Customer() {

    }

    @JsonProperty("customerId")
    public long getId() {
        return id;
    }

    public String getName() {
        return name;
    }

   @JsonIgnore   //屏蔽显示
    public String  getPassword(){
        return password;
    }

    public String getEmail() {
        return email;
    }

    @Override
    public String toString() {
        return "Customer{" +
                "password='" + password + '\'' +
                ", name='" + name + '\'' +
                ", id=" + id +
                ", email='" + email + '\'' +
                '}';
    }
}
